package org.boot.wxipad.support.config.impl;

import org.apache.commons.lang3.StringUtils;
import org.boot.wxipad.common.error.WxIpadRuntimeException;
import org.boot.wxipad.support.config.WxIpadConfigStorage;

import java.io.Serializable;

/**
 * @author liyuncong
 * @version 1.0
 * @file WxIpadConfigStorageImpl
 * @brief WxIpadConfigStorageImpl
 * @details WxIpadConfigStorageImpl
 * @date 2024-08-05
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2024-08-05               liyuncong          Created
 */
public class WxIpadConfigStorageImpl implements WxIpadConfigStorage, Serializable {

    private volatile String baseApiUrl;

    @Override
    public void setBaseApiUrl(String baseUrl) {
        this.baseApiUrl = baseUrl;
    }

    @Override
    public String getApiUrl(String path) {
        if (StringUtils.isBlank(baseApiUrl)) {
            throw new WxIpadRuntimeException("baseApiUrl must not be null.");
        }
        return baseApiUrl + path;
    }
}
